package pl.edu.mimuw.mas.agent.behaviour.deer;

import jade.lang.acl.ACLMessage;
import jade.lang.acl.MessageTemplate;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import pl.edu.mimuw.mas.agent.DeerAgent;
import pl.edu.mimuw.mas.agent.behaviour.ServerBehaviour;
import pl.edu.mimuw.mas.util.DeathHelper;

public class ShootServerBahaviour extends ServerBehaviour {

	private static final long serialVersionUID = 6848155598093669313L;
	
	protected final Logger logger = LoggerFactory.getLogger(getClass());

	public ShootServerBahaviour(DeerAgent agent) {
		super(agent);
		
		MessageTemplate mt = MessageTemplate.and(
				MessageTemplate.MatchConversationId(DeerAgent.SHOOT_CONV),
				MessageTemplate.MatchPerformative(ACLMessage.INFORM)
				);
		setMessageTemplate(mt);
	}

	@Override
	public boolean doAction(ACLMessage msg, ACLMessage reply) {
		logger.info("{} : I'm dying... Please, help!!!", myAgent.getName());
		
		DeathHelper.killDeer();
		
		return false;
	}

}
